package com.bdqn.business.academic.controller;

import com.bdqn.aop.Log;
import com.bdqn.business.academic.service.UpperService;
import com.bdqn.entity.academic.Upper;
import com.bdqn.response.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.Map;

@RestController
@RequestMapping("/upper")
public class UpperController {

    @Autowired
    private UpperService upperService;

    @Log("获取上机题列表")
    @RequestMapping(value = "/getList",method = RequestMethod.POST)
    public Result getList(@RequestBody Map<String,Object> map){
        return upperService.getList(map);
    }

    @Log("上传文件,新增上机题文件")
    @RequestMapping(value = "/upload",method = RequestMethod.POST)
    public Result upload(@RequestParam("file") MultipartFile file) throws IOException {
        return upperService.upload(file);
    }

    @Log("保存（修改）上机题")
    @RequestMapping(value = "/saveUpper",method = RequestMethod.POST)
    public Result saveUpper(@RequestBody Upper upper){
        return upperService.saveUpper(upper);
    }

    @Log("通过章节ID组查询试题集合")
    @RequestMapping(value = "/getUpperListByChapters",method = RequestMethod.POST)
    public Result getUpperListByChapters(@RequestBody Map<String,Object> map){
        return upperService.getUpperListByChapters(map);
    }
}
